package com.baidu.model;


import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;

/**
 * 回帖设置
 * @author libs
 * 2015-12-23
 */
public class Reply extends Model<Reply>{
	
	private static final long serialVersionUID = 282908528936842633L;
	public static final Reply dao = new Reply();
	/**
	 * 查询回帖设置列表
	 * @param mod 回帖模式
	 * @return
	 */
	public List<Reply> queryReplyList(Integer mod) {
		StringBuffer sql = new StringBuffer();
		sql.append("select a.*,c.bduss as bduss from reply a");
		sql.append(" left join bd_user c on c.guid=a.bdGuid");
		sql.append(" where a.isDeleted=0");
		sql.append(" and a.replyMod =?");
		sql.append(" and a.replyNum > (select count(d.guid) from reply_rec d where d.replyGuid = a.guid and DATE_FORMAT(d.replyTime,'%Y-%m-%d') = DATE_FORMAT(now(),'%Y-%m-%d'))");//限制回帖数量
		return find(sql.toString(), mod);
	}
	
	/**
	 * 根据百度guid删除回复
	 * @param para
	 */
    public void delByBDGuid(String guid) {
        Db.update("delete from reply where bdGuid = ?", guid);        
    }
	
}
